package com.example.controller;

import java.io.Serializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.entity.User;
import com.example.service.UserService;

@Controller // 注解为控制器
@RequestMapping(value = "/add") // 截获带有/login的请求
public class UserController {

	@Autowired
	private UserService userService;

	@RequestMapping()
	@ResponseBody
	public String post(User user) { // 用来处理用户的登陆请求
		Serializable save = userService.save(user);
		if (save != null) {
			return "success";
		} else {
			return "fail";
		}
	}
}